module Renderer

export magnitude_to_luminance_renderer
export single_ratio_colored_magnitude_renderer
export real_imag_color_renderer
"""

A renderer convers a complex number to RGB values so that it can be visualized.
Note that the value for each channel is represented by a float number between 
0 and 1. In 8-bit color space, 1 is translated to 2^8 while in 16-bit space, it 
could be 2^16

"""


function magnitude_to_luminance_renderer(c::Complex)::Tuple{Float64,Float64,Float64}
    abs_c = isnan(c) ? 0 : abs(c) / 3
    mag = min(1, abs_c)
    return mag, mag, mag
end

function single_ratio_colored_magnitude_renderer(c::Complex)::Tuple{Float64,Float64,Float64}
    r, g, b = magnitude_to_luminance_renderer(c)
    return 0.3 * r, 0.6 * g, 0.99 * b
end

function real_imag_color_renderer(c::Complex)::Tuple{Float64,Float64,Float64}
    r = min(isnan(c) ? 0 : abs(real(c)) / 2.5, 1)
    b = min(isnan(c) ? 0 : abs(imag(c)) / 2.5, 1)
    return r, 0, b
end
    
end # end module
